package com.dao;

import com.pojo.Role;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RoleMapper {
    @Select("select * from smbms_role where id = #{id}")
    public Role getRoleById(Integer id);

    @Select("select * from smbms_role")
    @Results({@Result(column = "roleName", property = "roleName"),
            @Result(column = "id", property = "userList", many =
            @Many(select="com.mapper.UserMapper.getUserListByRole"))})
    public List<Role> getAllRole();

    @Select("select * from smbms_role where id = #{id}")
    @Results({@Result(column = "roleName", property = "roleName"),
            @Result(column = "id", property = "userList", many =
            @Many(select="com.mapper.UserMapper.getUsersByRoleId"))})
    public Role getRoleAllUser(Integer id);
}
